package com.example.gsp.proxy;

import java.lang.reflect.Method;

public class TimeHandler implements InvocationHandler {

    private Object target;

    public TimeHandler(Object target) {
        super();
        this.target = target;
    }

    @Override
    public Object invoke(Object o, Method m, Object[] args) {
        long start = System.currentTimeMillis();
        System.out.println("starttime:" + start);
        System.out.println(o.getClass().getName());
        Object r = null;
        try {
            r = m.invoke(target, args);
        } catch (Exception e) {
            e.printStackTrace();
        }
        long end = System.currentTimeMillis();
        System.out.println("time:" + (end - start));
        return r;
    }

}
